package com.lolongmaps.main;

import com.lolongmaps.model.Details;
import com.lolongmaps.test.MainActivity;
import com.lolongmaps.test.R;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class InformationView extends Activity{
	
	Intent intent;
	Details detail;
	
	LinearLayout layout;
	Button button;
	TextView tvDetails, tvFeatures, space, featureTitle;
	String[] detailsValue = new String[6];
	
	public void onCreate(Bundle savedInstanceState){
		
		super.onCreate(savedInstanceState);
        setContentView(R.layout.infoview);
        
        this.intent = getIntent();
        this.detail = (Details)intent.getSerializableExtra("detailsObject");
        this.layout = (LinearLayout) findViewById(R.id.infoView);
        
        detailsValue[0] = this.detail.getName(); 
        detailsValue[1] = this.detail.getType(); 
        detailsValue[2] = this.detail.getLocation();
        detailsValue[3] = this.detail.getArea();
        detailsValue[4] = this.detail.getContactDetails();
        detailsValue[5] = this.detail.getPrice();
        
        
        
        int[] featuresStatus = {this.detail.getDeliveryStatus(), this.detail.getWifiStatus(), 
        						this.detail.getOpen24hrsStatus(), this.detail.getParkigStatus(), this.detail.getCreditCardStatus(),
        						this.detail.getBuffetStatus(), this.detail.getCateringStatus(), this.detail.getFunctionsStatus(),
        						this.detail.getReservationStatus(), this.detail.getEntertainmentStatus(), this.detail.getOffersVeganFoodStatus()};
        
        for(int detailsCounter = 0; detailsCounter < 6; detailsCounter++){
        	
        	tvDetails = new TextView(this);
        	tvDetails.setId(detailsCounter);
        	tvDetails.setBackgroundResource(R.drawable.buttons);
        	tvDetails.setTextColor(Color.BLACK);
        	tvDetails.setText(this.detail.getDetailName()[detailsCounter] + ": " + detailsValue[detailsCounter]);
        	this.layout.addView(tvDetails);
        	
        }
        
        this.space = new TextView(this);
        this.space.setText("");
        this.featureTitle = new TextView(this);
        this.featureTitle.setTextColor(Color.BLACK);
        this.featureTitle.setText("Features");
        this.layout.addView(space);
        this.layout.addView(featureTitle);
        
        for(int featureCounter = 0; featureCounter < 11; featureCounter++){
        	
        	if(featuresStatus[featureCounter] == 1){
        		
        		tvFeatures = new TextView(this);
            	tvFeatures.setTextColor(Color.BLACK);
            	tvFeatures.setBackgroundResource(R.drawable.buttons);
            	tvFeatures.setId(featureCounter);
        		
        		tvFeatures.setText(this.detail.getFeatureName()[featureCounter]);
        		
        		this.layout.addView(tvFeatures);
        		
        	}
        	
        	
        }
        
        
        this.button = new Button(this);
        this.button.setText("View Map");
        this.button.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				Intent mapView = new Intent(InformationView.this, MainActivity.class);
				String addrr = getLoc();
				mapView.putExtra("address", addrr);
				startActivity(mapView);
			}
			
        });
        
        this.layout.addView(button);
		
	}
	
	public String getLoc(){
		String endLoc = detailsValue[2];
		
		return endLoc;
	}

	
}
